/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.facilscrum.form.tablero;

import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumn;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
import net.sf.jasperreports.view.JasperViewer;
import org.facilscrum.beans.Backlog;
import org.facilscrum.beans.Burndown;
import org.javscaz.javscaztools.utilidades.Utilidades;
import org.facilscrum.beans.Proyectos;
import org.facilscrum.beans.Scrumdiario;
import org.facilscrum.beans.Sprint;
import org.facilscrum.beans.Tablero;
import org.facilscrum.beans.Userstories;
import org.facilscrum.beans.Userstoriessprint;
import org.facilscrum.beans.Userstoriessprinthistorial;
import org.facilscrum.controller.BurndownController;
import org.facilscrum.controller.ProyectosController;
import org.facilscrum.controller.ScrumdiarioController;
import org.facilscrum.controller.SprintController;
import org.facilscrum.controller.UserstoriesController;
import org.facilscrum.controller.UserstoriessprintController;
import org.facilscrum.controller.UserstoriessprinthistorialController;
import org.facilscrum.generales.Mensajeria;
import org.facilscrum.sesion.MySesion;
import org.javscaz.javscaztools.tablas.CustomEditor;
import org.javscaz.javscaztools.tablas.CustomRenderer;

/**
 *
 * @author avbravo
 */
public class TableroForm extends javax.swing.JInternalFrame {

    Burndown burndown = new Burndown();
    BurndownController burndownController = new BurndownController();
    Proyectos proyectos = new Proyectos();
    ProyectosController proyectosController = new ProyectosController();
    Sprint sprint = new Sprint();
    SprintController sprintController = new SprintController();
    Scrumdiario scrumdiario = new Scrumdiario();
    ScrumdiarioController scrumdiarioController = new ScrumdiarioController();
    Userstories userstories = new Userstories();
    UserstoriesController userstoriesController = new UserstoriesController();
    Userstoriessprint userstoriessprint = new Userstoriessprint();
    UserstoriessprintController userstoriessprintController = new UserstoriessprintController();
    Userstoriessprinthistorial userstoriessprinthistorial = new Userstoriessprinthistorial();
    UserstoriessprinthistorialController userstoriessprinthistorialController = new UserstoriessprinthistorialController();
    DefaultTableModel modelo, modeloSprint, modeloBurndown, modeloImpedimentos, modeloHistorial;
    List<Tablero> listTablero = new ArrayList();
        List<Tablero> listHistorial = new ArrayList();
    Integer totalPuntosPendientes = 0;
    Integer totalDiasSprint = 0;

    /**
     * Creates new form SprintForm
     */
    public TableroForm() {
        initComponents();
        modelo = (DefaultTableModel) jTableUserStories.getModel();
        modeloBurndown = (DefaultTableModel) jTableBurndown.getModel();
        modeloImpedimentos = (DefaultTableModel) jTableImpedimentos.getModel();
        modeloHistorial = (DefaultTableModel) jTableHistorial.getModel();
        java.util.Calendar ca = java.util.Calendar.getInstance();
        java.sql.Date mydate = new java.sql.Date(ca.getTimeInMillis());
        jXDatePickerFechaInicio.setDate(mydate);
        jXDatePickerFechaInicio.setFormats(new SimpleDateFormat("dd/MM/yyyy"));
        jXDatePickerFechaTerminacion.setDate(mydate);
        jXDatePickerFechaTerminacion.setFormats(new SimpleDateFormat("dd/MM/yyyy"));
        jXDatePickerFechaDemo.setDate(mydate);
        jXDatePickerFechaDemo.setFormats(new SimpleDateFormat("dd/MM/yyyy"));


                jXDatePickerFechaHistorial.setDate(mydate);
     jXDatePickerFechaHistorial.setFormats(new SimpleDateFormat("dd/MM/yyyy"));

        jXDatePickerFechaTablero.setDate(mydate);
        jXDatePickerFechaTablero.setFormats(new SimpleDateFormat("dd/MM/yyyy"));
        /*
         * para utilizar el jtextarea en la columan
         */
        TableColumn pendiente = jTableUserStories.getColumnModel().getColumn(0);
        pendiente.setCellRenderer(new CustomRenderer());
        pendiente.setCellEditor(new CustomEditor());

        TableColumn encurso = jTableUserStories.getColumnModel().getColumn(1);
        encurso.setCellRenderer(new CustomRenderer());
        encurso.setCellEditor(new CustomEditor());

        TableColumn terminado = jTableUserStories.getColumnModel().getColumn(2);
        terminado.setCellRenderer(new CustomRenderer());
        terminado.setCellEditor(new CustomEditor());

        
         TableColumn pendienteHistorial = jTableHistorial.getColumnModel().getColumn(0);
       pendienteHistorial.setCellRenderer(new CustomRenderer());
        pendienteHistorial.setCellEditor(new CustomEditor());

        TableColumn encursoHistorial = jTableHistorial.getColumnModel().getColumn(1);
        encursoHistorial .setCellRenderer(new CustomRenderer());
       encursoHistorial .setCellEditor(new CustomEditor());

        TableColumn terminadoHistorial = jTableHistorial.getColumnModel().getColumn(2);
       terminadoHistorial.setCellRenderer(new CustomRenderer());
        terminadoHistorial.setCellEditor(new CustomEditor());


        jTableUserStories.setRowHeight(85);
        if (!MySesion.getSeleccionoProyectoTrabajo()) {
            Mensajeria.MensajeWarning("Debe indicar el proyecto de trabajo");
        } else {
            proyectos = MySesion.getProyectos();
            jTextFieldProyecto.setText(proyectos.getProyecto());
            cargarComboSprint();

        }
        jTableUserStories.setAutoCreateRowSorter(true);

        TableColumn impedimentos = jTableImpedimentos.getColumnModel().getColumn(3);
        impedimentos.setCellRenderer(new CustomRenderer());
        impedimentos.setCellEditor(new CustomEditor());
        jTableImpedimentos.setRowHeight(85);
 jTableHistorial.setRowHeight(85);

        guardarHistorialTablero();
        guardarBurndown(false);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane2 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jButton3 = new javax.swing.JButton();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        jTableUserStories = new javax.swing.JTable();
        jPanel4 = new javax.swing.JPanel();
        jButtonImprimir = new javax.swing.JButton();
        jButtonRegresar = new javax.swing.JButton();
        jButtonGuardar = new javax.swing.JButton();
        jLabel13 = new javax.swing.JLabel();
        jXDatePickerFechaTablero = new org.jdesktop.swingx.JXDatePicker();
        jPanel9 = new javax.swing.JPanel();
        jPanel10 = new javax.swing.JPanel();
        jScrollPane7 = new javax.swing.JScrollPane();
        jTableBurndown = new javax.swing.JTable();
        jPanel11 = new javax.swing.JPanel();
        jLabel16 = new javax.swing.JLabel();
        jSliderDiaSprint = new javax.swing.JSlider();
        jLabelDiaSprint = new javax.swing.JLabel();
        jButtonGraficaBurndown = new javax.swing.JButton();
        jLabel18 = new javax.swing.JLabel();
        jPanel7 = new javax.swing.JPanel();
        jScrollPane5 = new javax.swing.JScrollPane();
        jTableImpedimentos = new javax.swing.JTable();
        jButtonReporteImpedimientos = new javax.swing.JButton();
        jPanel8 = new javax.swing.JPanel();
        jLabel14 = new javax.swing.JLabel();
        jScrollPane6 = new javax.swing.JScrollPane();
        jTableHistorial = new javax.swing.JTable();
        jLabel15 = new javax.swing.JLabel();
        jXDatePickerFechaHistorial = new org.jdesktop.swingx.JXDatePicker();
        jButtonFiltro = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextAreaObjetivo = new javax.swing.JTextArea();
        jLabel10 = new javax.swing.JLabel();
        jComboBoxSprint = new javax.swing.JComboBox();
        jTextFieldProyecto = new javax.swing.JTextField();
        jPanel2 = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jFormattedTextFieldVelocidadEstimada = new javax.swing.JFormattedTextField();
        jLabel7 = new javax.swing.JLabel();
        jTextFieldPuntosAsigandos = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jXDatePickerFechaInicio = new org.jdesktop.swingx.JXDatePicker();
        jLabel5 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jXDatePickerFechaDemo = new org.jdesktop.swingx.JXDatePicker();
        jLabel6 = new javax.swing.JLabel();
        jFormattedTextFieldHoraDemo = new javax.swing.JFormattedTextField();
        jXDatePickerFechaTerminacion = new org.jdesktop.swingx.JXDatePicker();
        jLabel8 = new javax.swing.JLabel();
        jLabelUltimaFecha = new javax.swing.JLabel();

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane2.setViewportView(jTable1);

        jButton3.setText("jButton3");

        setClosable(true);
        setTitle("TABLERO");

        jTableUserStories.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Pendiente", "En curso", "Terminado"
            }
        ));
        jScrollPane3.setViewportView(jTableUserStories);

        jPanel4.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jButtonImprimir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/facilscrum/gif/x16/print.png"))); // NOI18N
        jButtonImprimir.setEnabled(false);
        jButtonImprimir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonImprimirActionPerformed(evt);
            }
        });

        jButtonRegresar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/avbravo/jscrum/gif/return.gif"))); // NOI18N
        jButtonRegresar.setToolTipText("Regresar");
        jButtonRegresar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonRegresarActionPerformed(evt);
            }
        });

        jButtonGuardar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/facilscrum/gif/Save.png"))); // NOI18N
        jButtonGuardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonGuardarActionPerformed(evt);
            }
        });

        jLabel13.setText("Fecha Tablero");

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addComponent(jLabel13)
                .addGap(18, 18, 18)
                .addComponent(jXDatePickerFechaTablero, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(4, 4, 4)
                .addComponent(jButtonGuardar, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jButtonImprimir, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButtonRegresar, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jXDatePickerFechaTablero, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(jButtonImprimir, javax.swing.GroupLayout.DEFAULT_SIZE, 36, Short.MAX_VALUE)
                        .addComponent(jButtonRegresar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jButtonGuardar, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
                    .addComponent(jLabel13))
                .addContainerGap(56, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jPanel4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 856, Short.MAX_VALUE))
                .addGap(0, 71, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 293, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jTabbedPane1.addTab("User Stories", jPanel1);

        jPanel10.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jTableBurndown.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Dia", "Fecha", "Puntos"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane7.setViewportView(jTableBurndown);

        jPanel11.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel16.setText("Dia del sprint");

        jSliderDiaSprint.setToolTipText("Dia del sprint");
        jSliderDiaSprint.setEnabled(false);
        jSliderDiaSprint.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                jSliderDiaSprintStateChanged(evt);
            }
        });

        jLabelDiaSprint.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N
        jLabelDiaSprint.setText("0");

        jButtonGraficaBurndown.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/facilscrum/gif/x32/burndown.png"))); // NOI18N
        jButtonGraficaBurndown.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonGraficaBurndownActionPerformed(evt);
            }
        });

        jLabel18.setText("Total de dias del sprint");

        javax.swing.GroupLayout jPanel11Layout = new javax.swing.GroupLayout(jPanel11);
        jPanel11.setLayout(jPanel11Layout);
        jPanel11Layout.setHorizontalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel18)
                    .addGroup(jPanel11Layout.createSequentialGroup()
                        .addComponent(jLabel16)
                        .addGap(33, 33, 33)
                        .addComponent(jSliderDiaSprint, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jLabelDiaSprint, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel11Layout.createSequentialGroup()
                        .addGap(79, 79, 79)
                        .addComponent(jButtonGraficaBurndown, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(24, 62, Short.MAX_VALUE))
        );
        jPanel11Layout.setVerticalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addGap(22, 22, 22)
                .addComponent(jLabel18)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel16)
                    .addComponent(jSliderDiaSprint, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel11Layout.createSequentialGroup()
                        .addGap(8, 8, 8)
                        .addComponent(jLabelDiaSprint)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButtonGraficaBurndown, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(50, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel10Layout = new javax.swing.GroupLayout(jPanel10);
        jPanel10.setLayout(jPanel10Layout);
        jPanel10Layout.setHorizontalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel10Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, 370, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(49, Short.MAX_VALUE))
        );
        jPanel10Layout.setVerticalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel10Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, 199, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
        jPanel9.setLayout(jPanel9Layout);
        jPanel9Layout.setHorizontalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addGap(26, 26, 26)
                .addComponent(jPanel10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(395, Short.MAX_VALUE))
        );
        jPanel9Layout.setVerticalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Burndown", jPanel9);

        jTableImpedimentos.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Id", "Fecha", "Usuario", "Impedimento"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                true, false, false, true
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane5.setViewportView(jTableImpedimentos);

        jButtonReporteImpedimientos.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/facilscrum/gif/print.png"))); // NOI18N
        jButtonReporteImpedimientos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonReporteImpedimientosActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addGap(159, 159, 159)
                .addComponent(jButtonReporteImpedimientos, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(701, Short.MAX_VALUE))
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 638, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel7Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jButtonReporteImpedimientos, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 325, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(104, 104, 104))
        );

        jTabbedPane1.addTab("Impedimientos", jPanel7);

        jTableHistorial.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Pendiente", "En curso", "Terminado"
            }
        ));
        jScrollPane6.setViewportView(jTableHistorial);

        jLabel15.setText("Fecha Historial");

        jButtonFiltro.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/facilscrum/gif/x16/filter.png"))); // NOI18N
        jButtonFiltro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonFiltroActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabel14)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel15)
                .addGap(18, 18, 18)
                .addComponent(jXDatePickerFechaHistorial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jButtonFiltro, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(623, 623, 623))
            .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel8Layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jScrollPane6, javax.swing.GroupLayout.DEFAULT_SIZE, 911, Short.MAX_VALUE)
                    .addContainerGap()))
        );
        jPanel8Layout.setVerticalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel14)
                    .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jXDatePickerFechaHistorial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jButtonFiltro))
                        .addComponent(jLabel15)))
                .addContainerGap(371, Short.MAX_VALUE))
            .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel8Layout.createSequentialGroup()
                    .addGap(63, 63, 63)
                    .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 293, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(63, Short.MAX_VALUE)))
        );

        jTabbedPane1.addTab("Historial", jPanel8);

        jPanel3.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel1.setText("Proyecto");

        jLabel2.setText("Objetivo");

        jTextAreaObjetivo.setColumns(20);
        jTextAreaObjetivo.setRows(5);
        jTextAreaObjetivo.setEnabled(false);
        jScrollPane1.setViewportView(jTextAreaObjetivo);

        jLabel10.setText("Sprint");

        jComboBoxSprint.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBoxSprintActionPerformed(evt);
            }
        });

        jTextFieldProyecto.setEnabled(false);

        jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel3.setText("Velocidad Estimada");

        jFormattedTextFieldVelocidadEstimada.setEditable(false);
        jFormattedTextFieldVelocidadEstimada.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("####"))));
        jFormattedTextFieldVelocidadEstimada.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N

        jLabel7.setText("Puntos asignados");

        jTextFieldPuntosAsigandos.setEditable(false);
        jTextFieldPuntosAsigandos.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N
        jTextFieldPuntosAsigandos.setForeground(javax.swing.UIManager.getDefaults().getColor("CheckBoxMenuItem.selectionBackground"));

        jLabel4.setText("Fecha Inicio");

        jXDatePickerFechaInicio.setEnabled(false);

        jLabel5.setText("Terminacion");

        jLabel9.setText("Fecha demo");

        jXDatePickerFechaDemo.setEnabled(false);

        jLabel6.setText("Hora demo");

        jFormattedTextFieldHoraDemo.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.DateFormatter(new java.text.SimpleDateFormat("H:mm"))));
        jFormattedTextFieldHoraDemo.setText("03:00");
        jFormattedTextFieldHoraDemo.setEnabled(false);

        jXDatePickerFechaTerminacion.setEnabled(false);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jFormattedTextFieldVelocidadEstimada, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel7)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jTextFieldPuntosAsigandos, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(jLabel4)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jXDatePickerFechaInicio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(jLabel5))
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(jLabel9)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jXDatePickerFechaDemo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel6)))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(jFormattedTextFieldHoraDemo, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(jXDatePickerFechaTerminacion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(0, 0, Short.MAX_VALUE))))))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jFormattedTextFieldVelocidadEstimada, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7)
                    .addComponent(jTextFieldPuntosAsigandos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel4)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jXDatePickerFechaInicio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel5)
                        .addComponent(jXDatePickerFechaTerminacion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel9)
                        .addComponent(jXDatePickerFechaDemo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel6))
                    .addComponent(jFormattedTextFieldHoraDemo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(25, Short.MAX_VALUE))
        );

        jLabel8.setText("Ultima fecha que se guardo tablero");

        jLabelUltimaFecha.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N
        jLabelUltimaFecha.setText("00/00/0000");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addComponent(jLabel2)
                                .addGap(18, 18, 18)
                                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 321, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel1)
                                    .addComponent(jLabel10))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jComboBoxSprint, javax.swing.GroupLayout.PREFERRED_SIZE, 275, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jTextFieldProyecto, javax.swing.GroupLayout.PREFERRED_SIZE, 285, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jLabel8)
                        .addGap(18, 18, 18)
                        .addComponent(jLabelUltimaFecha)))
                .addGap(49, 49, 49)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel1)
                            .addComponent(jTextFieldProyecto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel10)
                            .addComponent(jComboBoxSprint, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel2))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel8)
                            .addComponent(jLabelUltimaFecha)))
                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 935, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(55, 55, 55))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 456, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(26, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButtonRegresarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonRegresarActionPerformed
        dispose();
    }//GEN-LAST:event_jButtonRegresarActionPerformed

    private void jComboBoxSprintActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxSprintActionPerformed
        try {
            int j = jComboBoxSprint.getSelectedIndex();
            if (j != -1) {
                sprint = sprintController.getSprintlist().get(j);

                totalDiasSprint = MySesion.diasDiferencia(sprint.getFechaterminacion(), sprint.getFechainicio());
                jSliderDiaSprint.setMaximum(MySesion.diasDiferencia(sprint.getFechaterminacion(), sprint.getFechainicio()));

                jLabelDiaSprint.setText(String.valueOf(totalDiasSprint));

                jTextAreaObjetivo.setText(sprint.getObjetivo());
                jFormattedTextFieldVelocidadEstimada.setText(sprint.getVelocidadestimada().toString());
                jFormattedTextFieldVelocidadEstimada.setText(sprint.getVelocidadestimada().toString());
                jFormattedTextFieldHoraDemo.setText(sprint.getHorademo().toString());
                jXDatePickerFechaInicio.setDate(sprint.getFechainicio());
                jXDatePickerFechaInicio.setFormats(new SimpleDateFormat("dd/MM/yyyy"));
                jXDatePickerFechaTerminacion.setDate(sprint.getFechaterminacion());
                jXDatePickerFechaTerminacion.setFormats(new SimpleDateFormat("dd/MM/yyyy"));
                jXDatePickerFechaDemo.setDate(sprint.getFechademo());
                jXDatePickerFechaDemo.setFormats(new SimpleDateFormat("dd/MM/yyyy"));
                jTextFieldPuntosAsigandos.setText(sprint.getPuntosasignados().toString());
                cargarTablaUserStoriesAsignados();
                cargarTablaDailyScrum();
                cargarTablaBurndown();
                String sql = "idsprint='" + sprint.getIdsprint() + "' order by fecha desc";
                if (userstoriessprinthistorialController.query(sql)) {
                    java.sql.Date fecha = userstoriessprinthistorialController.getUserstoriessprinthistoriallist().get(0).getFecha();
                    String fechaS = MySesion.formatearFechaToString(fecha);
                    String hora = String.valueOf(userstoriessprinthistorialController.getUserstoriessprinthistoriallist().get(0).getHora());
                    jLabelUltimaFecha.setText(fechaS + " " + hora);

                }
            }
        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "comboProyecto()");
        }
    }//GEN-LAST:event_jComboBoxSprintActionPerformed

    private void jButtonImprimirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonImprimirActionPerformed
        HashMap map = new HashMap();
        map.put("p_proyecto", MySesion.getProyectos().getProyecto());
        map.put("p_sprint", sprint.getNombre());
        map.put("p_velocidad", jFormattedTextFieldVelocidadEstimada.getText());
        map.put("p_puntos", jTextFieldPuntosAsigandos.getText());
        map.put("p_inicio", MySesion.formatearFechaToString(sprint.getFechainicio()));
        map.put("p_terminacion", MySesion.formatearFechaToString(sprint.getFechaterminacion()));
        map.put("p_demofecha", MySesion.formatearFechaToString(sprint.getFechademo()));
        map.put("p_demohora", sprint.getHorademo());
        try {
            imprimir(listTablero, map);
        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "imprimir()");
        }
    }//GEN-LAST:event_jButtonImprimirActionPerformed

    private void jButtonReporteImpedimientosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonReporteImpedimientosActionPerformed
        HashMap map = new HashMap();
        map.put("p_proyecto", MySesion.getProyectos().getProyecto());
        map.put("p_sprint", sprint.getNombre());
        map.put("p_velocidad", jFormattedTextFieldVelocidadEstimada.getText());
        map.put("p_puntos", jTextFieldPuntosAsigandos.getText());
        map.put("p_inicio", MySesion.formatearFechaToString(sprint.getFechainicio()));
        map.put("p_terminacion", MySesion.formatearFechaToString(sprint.getFechaterminacion()));
        map.put("p_demofecha", MySesion.formatearFechaToString(sprint.getFechademo()));
        map.put("p_demohora", sprint.getHorademo());
        try {
            imprimirImpedimentos(scrumdiarioController.getScrumdiariolist(), map);
        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "imprimir()");
        }
    }//GEN-LAST:event_jButtonReporteImpedimientosActionPerformed

    private void jButtonGuardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonGuardarActionPerformed
        guardarHistorialTablero();
        guardarBurndown(true);
    }//GEN-LAST:event_jButtonGuardarActionPerformed

    private void jSliderDiaSprintStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jSliderDiaSprintStateChanged
        jLabelDiaSprint.setText(String.valueOf(jSliderDiaSprint.getValue()));
    }//GEN-LAST:event_jSliderDiaSprintStateChanged

    private void jButtonGraficaBurndownActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonGraficaBurndownActionPerformed
        HashMap map = new HashMap();
        map.put("p_proyecto", MySesion.getProyectos().getProyecto());
        map.put("p_sprint", sprint.getNombre());
        map.put("p_velocidad", jFormattedTextFieldVelocidadEstimada.getText());
        map.put("p_puntos", jTextFieldPuntosAsigandos.getText());
        map.put("p_inicio", MySesion.formatearFechaToString(sprint.getFechainicio()));
        map.put("p_terminacion", MySesion.formatearFechaToString(sprint.getFechaterminacion()));
        map.put("p_demofecha", MySesion.formatearFechaToString(sprint.getFechademo()));
        map.put("p_demohora", sprint.getHorademo());
        try {
            BurndownController bc = new BurndownController();
            String query = "idsprint='" + sprint.getIdsprint() + "' order by idsprint";
            if (bc.query(query)) {
                imprimirBurndown(bc.getBurndownlist(), map);
            }
        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "imprimir()");
        }
    }//GEN-LAST:event_jButtonGraficaBurndownActionPerformed

    private void jButtonFiltroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonFiltroActionPerformed
cargarTablaUserStoriesHistorial();
    }//GEN-LAST:event_jButtonFiltroActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButtonFiltro;
    private javax.swing.JButton jButtonGraficaBurndown;
    private javax.swing.JButton jButtonGuardar;
    private javax.swing.JButton jButtonImprimir;
    private javax.swing.JButton jButtonRegresar;
    private javax.swing.JButton jButtonReporteImpedimientos;
    private javax.swing.JComboBox jComboBoxSprint;
    private javax.swing.JFormattedTextField jFormattedTextFieldHoraDemo;
    private javax.swing.JFormattedTextField jFormattedTextFieldVelocidadEstimada;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JLabel jLabelDiaSprint;
    private javax.swing.JLabel jLabelUltimaFecha;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel10;
    private javax.swing.JPanel jPanel11;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JScrollPane jScrollPane7;
    private javax.swing.JSlider jSliderDiaSprint;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTable jTable1;
    private javax.swing.JTable jTableBurndown;
    private javax.swing.JTable jTableHistorial;
    private javax.swing.JTable jTableImpedimentos;
    private javax.swing.JTable jTableUserStories;
    private javax.swing.JTextArea jTextAreaObjetivo;
    private javax.swing.JTextField jTextFieldProyecto;
    private javax.swing.JTextField jTextFieldPuntosAsigandos;
    private org.jdesktop.swingx.JXDatePicker jXDatePickerFechaDemo;
    private org.jdesktop.swingx.JXDatePicker jXDatePickerFechaHistorial;
    private org.jdesktop.swingx.JXDatePicker jXDatePickerFechaInicio;
    private org.jdesktop.swingx.JXDatePicker jXDatePickerFechaTablero;
    private org.jdesktop.swingx.JXDatePicker jXDatePickerFechaTerminacion;
    // End of variables declaration//GEN-END:variables

    private void guardarBurndown(Boolean iniciado) {
        try {

            java.util.Date Fecha = jXDatePickerFechaTablero.getDate();
            java.sql.Date fechaBurndown = new java.sql.Date(Fecha.getTime());
            if (fechaBurndown == null) {
                Mensajeria.Mensaje("Seleccione la fecha del tablero");
                jXDatePickerFechaTablero.requestFocus();
                return;
            }

            Integer diasprint = burndownController.func("max", "diasprint", "idsprint='" + sprint.getIdsprint() + "'").intValue();

            String query = "idsprint='" + sprint.getIdsprint() + "' and fecha='" + fechaBurndown + "'";

            if (!burndownController.query(query)) {
                if (diasprint >= totalDiasSprint) {
                    if (iniciado) {
                        Mensajeria.MensajeWarning("Ya se registraron todos los dias del burndown para este  sprint");
                    }

                    return;
                }
                burndown.setFecha(fechaBurndown);
                burndown.setIdsprint(sprint.getIdsprint());
                burndown.setPuntos(totalPuntosPendientes);
                burndown.setDiasprint(diasprint + 1);
                if (!burndownController.insert(burndown)) {
                    Mensajeria.MensajeWarning("no se pudo guardar burndown " + burndownController.getMensaje());
                } else {
                    cargarTablaBurndown();
//                    jButtonBurndown.setEnabled(true);
                }
            } else {
                if (iniciado) {
                    if (Mensajeria.PreguntaSiNo("Ya se registro el los puntos para este dia\nDesea usted actualizarlos o verificar la fecha\nFecha:" + MySesion.formatearFechaToString(fechaBurndown), "Fecha registrada anteriormende").equals("no")) {
                        return;
                    }
                }
                Burndown b = burndownController.getBurndownlist().get(0);
                b.setPuntos(totalPuntosPendientes);
                if (!burndownController.update(b)) {
                    Mensajeria.MensajeWarning("no se pudo guardar burndown " + burndownController.getMensaje());
                } else {
                    cargarTablaBurndown();
//                    jButtonBurndown.setEnabled(true);
                }
            }
        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "guardarBurndown()");
        }

    }

    private Boolean cargarComboSprint() {
        try {
            jComboBoxSprint.removeAllItems();
            String where = "idproyecto='" + proyectos.getIdproyecto() + "' and abierto='si' and puntosasignados > 0";
            if (sprintController.query(where)) {
                for (Sprint s : sprintController.getSprintlist()) {
                    jComboBoxSprint.addItem(s.getIdsprint() + " - " + s.getNombre());
                }
                return true;
            }
        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "cargarComboSprint() ");
        }
        return false;
    }
    /*
     *  cargarTablaUserStories()
     */

    private void cargarTablaUserStoriesAsignados() {
        try {
            List<Userstoriessprint> listPendiente = new ArrayList<>();
            List<Userstoriessprint> listEnCurso = new ArrayList<>();
            List<Userstoriessprint> listTerminado = new ArrayList<>();
            modelo = Utilidades.limpiarModelo(modelo);
            listTablero.removeAll(listTablero);
            Integer pendientesContador = 0;
            Integer encursoContador = 0;
            Integer terminadoContador = 0;
            String sql = "idsprint='" + sprint.getIdsprint() + "' and estatus='pendiente'";
            if (userstoriessprintController.query(sql)) {
                for (Userstoriessprint u : userstoriessprintController.getUserstoriessprintlist()) {
                    listPendiente.add(u);
                }
            }
            sql = "idsprint='" + sprint.getIdsprint() + "' and estatus='en curso'";
            if (userstoriessprintController.query(sql)) {
                for (Userstoriessprint u : userstoriessprintController.getUserstoriessprintlist()) {
                    listEnCurso.add(u);
                }
            }
            sql = "idsprint='" + sprint.getIdsprint() + "' and estatus='terminado'";
            if (userstoriessprintController.query(sql)) {
                for (Userstoriessprint u : userstoriessprintController.getUserstoriessprintlist()) {
                    listTerminado.add(u);
                }
            }
            Integer rowsPendientes = listPendiente.size();
            Integer rowsEnCurso = listEnCurso.size();
            Integer rowsTerminado = listTerminado.size();
            Integer totalRows = listPendiente.size() + listEnCurso.size() + listTerminado.size();
            if (rowsPendientes.equals(rowsEnCurso) && rowsPendientes.equals(rowsTerminado)) {
                totalRows = rowsPendientes;
            }
            if (rowsPendientes > rowsEnCurso && rowsPendientes > rowsTerminado) {
                totalRows = rowsTerminado;
            }
            if (rowsPendientes > rowsEnCurso && rowsPendientes > rowsTerminado) {
                totalRows = rowsPendientes;
            } else {
                if (rowsEnCurso > rowsTerminado) {
                    totalRows = rowsEnCurso;
                } else {
                    totalRows = rowsTerminado;
                }
            }
            totalPuntosPendientes = 0;
            if (totalRows > 0) {

                Object[] filas = new Object[3]; // Hay tres columnas en la tabla       
                filas[0] = "";
                filas[1] = "";
                filas[2] = "";
                for (int i = 0; i < totalRows; i++) {
                    Tablero tablero = new Tablero();
                    if (pendientesContador < listPendiente.size() && listPendiente.size() > 0) {
                        Userstoriessprint u = listPendiente.get(i);
                        String texto = "[" + u.getIduserstories() + "]" + u.getUserstories().getNombre() + "\n      Imp.(" + u.getUserstories().getImportancia() + ")" + "   Puntos:(" + u.getUserstories().getPuntos() + ")\n      " + u.getUserstories().getUsername();
                        filas[0] = texto;
                        pendientesContador++;
                        totalPuntosPendientes += u.getUserstories().getPuntos();
                    } else {
                        filas[0] = "";
                    }
                    tablero.setPendiente(filas[0].toString());
                    if (encursoContador < listEnCurso.size() && listEnCurso.size() > 0) {

                        Userstoriessprint u = listEnCurso.get(i);
                        String texto = "[" + u.getIduserstories() + "]" + u.getUserstories().getNombre() + "\n      Imp.(" + u.getUserstories().getImportancia() + ")" + "   Puntos:(" + u.getUserstories().getPuntos() + ")\n     " + u.getUserstories().getUsername();
                        filas[1] = texto;
                        encursoContador++;
                        totalPuntosPendientes += u.getUserstories().getPuntos();
                    } else {
                        filas[1] = "";
                    }
                    tablero.setEncurso(filas[1].toString());
                    if (terminadoContador < listTerminado.size() && listTerminado.size() > 0) {

                        Userstoriessprint u = listTerminado.get(i);
                        String texto = "[" + u.getIduserstories() + "]" + u.getUserstories().getNombre() + "\n      Imp.(" + u.getUserstories().getImportancia() + ")" + "   Puntos:(" + u.getUserstories().getPuntos() + ")\n      " + u.getUserstories().getUsername();
                        filas[2] = texto;
                        terminadoContador++;

                    } else {
                        filas[2] = "";
                    }
                    tablero.setTerminado(filas[2].toString());
                    modelo.addRow(filas);
                    listTablero.add(tablero);
                }
                jButtonImprimir.setEnabled(true);

            } else {
                Mensajeria.MensajeWarning("No hay user stories asignados a este sprint");
            }

        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "cargarTablaUserStoriesAsignados()");
        }
    }

    
    private void cargarTablaUserStoriesHistorial() {
        try {
            List<Userstoriessprinthistorial> listPendiente = new ArrayList<>();
            List<Userstoriessprinthistorial> listEnCurso = new ArrayList<>();
            List<Userstoriessprinthistorial> listTerminado = new ArrayList<>();
            modeloHistorial = Utilidades.limpiarModelo(modeloHistorial);
            listHistorial.removeAll(listHistorial);
            Integer pendientesContador = 0;
            Integer encursoContador = 0;
            Integer terminadoContador = 0;
              java.util.Date Fecha = jXDatePickerFechaHistorial.getDate();
            java.sql.Date fecha = new java.sql.Date(Fecha.getTime());
            if (fecha == null) {
                Mensajeria.MensajeWarning("Seleccione la fecha del historial");
               jXDatePickerFechaHistorial.requestFocus();
                return;
            }
            String sql = "idsprint='" + sprint.getIdsprint() + "' and estatus='pendiente' and fecha='"+fecha+"'";
            if (userstoriessprinthistorialController.query(sql)) {
                for (Userstoriessprinthistorial u : userstoriessprinthistorialController.getUserstoriessprinthistoriallist()) {
                    listPendiente.add(u);
                }
            }
            sql = "idsprint='" + sprint.getIdsprint() + "' and estatus='en curso' and fecha='"+fecha+"'";
           if (userstoriessprinthistorialController.query(sql)) {
                for (Userstoriessprinthistorial u : userstoriessprinthistorialController.getUserstoriessprinthistoriallist()) {
                    listEnCurso.add(u);
                }
            }
            sql = "idsprint='" + sprint.getIdsprint() + "' and estatus='terminado' and fecha='"+fecha+"'";
            if (userstoriessprinthistorialController.query(sql)) {
                for (Userstoriessprinthistorial u : userstoriessprinthistorialController.getUserstoriessprinthistoriallist()) {
                    listTerminado.add(u);
                }
            }
            Integer rowsPendientes = listPendiente.size();
            Integer rowsEnCurso = listEnCurso.size();
            Integer rowsTerminado = listTerminado.size();
            Integer totalRows = listPendiente.size() + listEnCurso.size() + listTerminado.size();
            if (rowsPendientes.equals(rowsEnCurso) && rowsPendientes.equals(rowsTerminado)) {
                totalRows = rowsPendientes;
            }
            if (rowsPendientes > rowsEnCurso && rowsPendientes > rowsTerminado) {
                totalRows = rowsTerminado;
            }
            if (rowsPendientes > rowsEnCurso && rowsPendientes > rowsTerminado) {
                totalRows = rowsPendientes;
            } else {
                if (rowsEnCurso > rowsTerminado) {
                    totalRows = rowsEnCurso;
                } else {
                    totalRows = rowsTerminado;
                }
            }
            totalPuntosPendientes = 0;
            if (totalRows > 0) {

                Object[] filas = new Object[3]; // Hay tres columnas en la tabla       
                filas[0] = "";
                filas[1] = "";
                filas[2] = "";
                for (int i = 0; i < totalRows; i++) {
                    Tablero tablero = new Tablero();
                    if (pendientesContador < listPendiente.size() && listPendiente.size() > 0) {
                        Userstoriessprinthistorial u = listPendiente.get(i);
                        String texto = "[" + u.getIduserstories() + "]" + u.getUserstories().getNombre() + "\n      Imp.(" + u.getUserstories().getImportancia() + ")" + "   Puntos:(" + u.getUserstories().getPuntos() + ")\n      " + u.getUserstories().getUsername();
                        filas[0] = texto;
                        pendientesContador++;
                        totalPuntosPendientes += u.getUserstories().getPuntos();
                    } else {
                        filas[0] = "";
                    }
                    tablero.setPendiente(filas[0].toString());
                    if (encursoContador < listEnCurso.size() && listEnCurso.size() > 0) {

                        Userstoriessprinthistorial u = listEnCurso.get(i);
                        String texto = "[" + u.getIduserstories() + "]" + u.getUserstories().getNombre() + "\n      Imp.(" + u.getUserstories().getImportancia() + ")" + "   Puntos:(" + u.getUserstories().getPuntos() + ")\n     " + u.getUserstories().getUsername();
                        filas[1] = texto;
                        encursoContador++;
                        totalPuntosPendientes += u.getUserstories().getPuntos();
                    } else {
                        filas[1] = "";
                    }
                    tablero.setEncurso(filas[1].toString());
                    if (terminadoContador < listTerminado.size() && listTerminado.size() > 0) {

                        Userstoriessprinthistorial u = listTerminado.get(i);
                        String texto = "[" + u.getIduserstories() + "]" + u.getUserstories().getNombre() + "\n      Imp.(" + u.getUserstories().getImportancia() + ")" + "   Puntos:(" + u.getUserstories().getPuntos() + ")\n      " + u.getUserstories().getUsername();
                        filas[2] = texto;
                        terminadoContador++;

                    } else {
                        filas[2] = "";
                    }
                    tablero.setTerminado(filas[2].toString());
                    modeloHistorial.addRow(filas);
                    listHistorial.add(tablero);
                }
                jButtonImprimir.setEnabled(true);

            } else {
                Mensajeria.MensajeWarning("No hay user stories asignados a este sprint en el historial");
            }

        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "cargarTablaUserStoriesAsignados()");
        }
    }

    private void guardar() {
        try {
            Integer row = modelo.getRowCount();
            if (row == 0) {
                Mensajeria.MensajeWarning("No hay ningun user stories disponibles");
                return;
            }
            int n = jTableUserStories.getRowCount();
            actualizarEstatusUserstoriessprint();
            Mensajeria.Mensaje("Proceso terminado");
        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "guardar()");
        }
    }

    private void limpiar() {
        jTextAreaObjetivo.setText("");
        jFormattedTextFieldVelocidadEstimada.setText("0");
        jFormattedTextFieldHoraDemo.setText("03:00");
        jTextFieldPuntosAsigandos.setText("0");
    }

    private Boolean actualizarEstatusUserstoriessprint() {
        try {
            int n = jTableUserStories.getRowCount();
            Integer iduserstories = 0;
            String estatus;
            for (int i = 0; i < n; i++) {
                estatus = jTableUserStories.getValueAt(i, 0).toString();
                iduserstories = Integer.parseInt(jTableUserStories.getValueAt(i, 1).toString());
                String sql = "estatus ='" + estatus + "' where iduserstories='" + iduserstories + "' and idsprint='" + sprint.getIdsprint() + "'";
                if (!userstoriessprintController.update(sql)) {
                    Mensajeria.MensajeWarning("No se pudo actualizar el estatus de  (" + iduserstories + ")\n" + userstoriessprintController.getMensaje());
                }
            }
            return true;
        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "actualizarEstatusUserstories()");
        }
        return false;
    }

    private void imprimir(List<Tablero> aux, HashMap map) throws JRException {
        try {
            JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(aux);
//Indicamos la ruta del reporte
            InputStream reporte = (InputStream) getClass().getResourceAsStream("/org/facilscrum/reportes/tablero.jasper");
            if (reporte == null) {
                Mensajeria.Mensaje("No se pudo cargar el reporte");
            } else {
                JasperPrint print = JasperFillManager.fillReport(reporte, map, ds);
                JasperViewer.viewReport(print, false);
            }
        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "Imprimir()");
        }
    }

    private void imprimirImpedimentos(List<Scrumdiario> aux, HashMap map) throws JRException {
        try {
            JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(aux);
//Indicamos la ruta del reporte
            InputStream reporte = (InputStream) getClass().getResourceAsStream("/org/facilscrum/reportes/impedimentos.jasper");
            if (reporte == null) {
                Mensajeria.Mensaje("No se pudo cargar el reporte");
            } else {
                JasperPrint print = JasperFillManager.fillReport(reporte, map, ds);
                JasperViewer.viewReport(print, false);
            }
        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "Imprimir()");
        }
    }

    private void imprimirBurndown(List<Burndown> aux, HashMap map) throws JRException {
        try {
            JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(aux);
//Indicamos la ruta del reporte
            InputStream reporte = (InputStream) getClass().getResourceAsStream("/org/facilscrum/reportes/burndown.jasper");
            if (reporte == null) {
                Mensajeria.Mensaje("No se pudo cargar el reporte");
            } else {
                JasperPrint print = JasperFillManager.fillReport(reporte, map, ds);
                JasperViewer.viewReport(print, false);
            }
        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "Imprimir()");
        }
    }

    private void cargarTablaBurndown() {
        try {
            jSliderDiaSprint.setValue(0);
            jButtonGraficaBurndown.setEnabled(false);
            modeloBurndown = Utilidades.limpiarModelo(modeloBurndown);
            String query = "idsprint='" + sprint.getIdsprint() + "' order by diasprint";
            if (burndownController.query(query)) {
                for (Burndown b : burndownController.getBurndownlist()) {
                    Object[] filas = new Object[3]; // Hay tres columnas en la tabla       
                    filas[0] = b.getDiasprint();
                    filas[1] = MySesion.formatearFechaToString(b.getFecha());
                    filas[2] = b.getPuntos();
                    jSliderDiaSprint.setValue(b.getDiasprint());
                    jLabelDiaSprint.setText(String.valueOf(b.getDiasprint()));
                    modeloBurndown.addRow(filas);
                    if (MySesion.getFechausername().after(b.getFecha()) || MySesion.getFechausername() == b.getFecha()) {
//                        jButtonBurndown.setEnabled(true);
                    }
                }
                jButtonGraficaBurndown.setEnabled(true);
            }
        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "cargarTablaBurndown()");
        }
    }

    private void cargarTablaDailyScrum() {
        try {
            jButtonReporteImpedimientos.setEnabled(false);
            modeloImpedimentos = Utilidades.limpiarModelo(modeloImpedimentos);
            String where = "idsprint='" + sprint.getIdsprint() + "' ";
            if (scrumdiarioController.query(where)) {
                for (Scrumdiario s : scrumdiarioController.getScrumdiariolist()) {
                    Object[] filas = new Object[4]; // Hay tres columnas en la tabla       
                    filas[0] = s.getIdscrumdiario();
                    filas[1] = MySesion.formatearFechaToString(s.getFecha());
                    filas[2] = s.getUsuarios().getNombre();
                    filas[3] = s.getInconvenientes();

                    modeloImpedimentos.addRow(filas);
                }
            }
            {
                jButtonReporteImpedimientos.setEnabled(true);
            }

        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "cargarTablaDailyScrum()");
        }
    }

    private void guardarHistorialTablero() {
        try {
            UserstoriessprintController usc = new UserstoriessprintController();
            java.util.Date Fecha = jXDatePickerFechaTablero.getDate();
            java.sql.Date fechaTablero = new java.sql.Date(Fecha.getTime());
            if (fechaTablero == null) {
                Mensajeria.Mensaje("Seleccione la fecha del burndwon");
                jXDatePickerFechaTablero.requestFocus();
                return;
            }
            String sql = "idsprint='" + sprint.getIdsprint() + "'";
            if (usc.query(sql)) {
                for (Userstoriessprint u : usc.getUserstoriessprintlist()) {
                    userstoriessprinthistorial.setEstatus(u.getEstatus());
                    //userstoriessprinthistorial.setFecha(MySesion.getFechausername());
                    userstoriessprinthistorial.setFecha(fechaTablero);
                    userstoriessprinthistorial.setIdsprint(u.getIdsprint());
                    userstoriessprinthistorial.setIduserstories(u.getIduserstories());
                    userstoriessprinthistorial.setSprint(u.getSprint());
                    userstoriessprinthistorial.setUserstories(u.getUserstories());
                    userstoriessprinthistorial.setHora(MySesion.getHoraSistema());
                    sql = "idsprint='" + sprint.getIdsprint() + "' and iduserstories='" + u.getIduserstories() + "' and fecha='" + MySesion.getFechausername() + "'";
                    if (userstoriessprinthistorialController.query(sql)) {
                        userstoriessprinthistorial.setIduserstoriessprinthistorial(userstoriessprinthistorialController.getUserstoriessprinthistoriallist().get(0).getIduserstoriessprinthistorial());
                        if (!userstoriessprinthistorialController.update(userstoriessprinthistorial)) {
                            Mensajeria.MensajeWarning("No se pudo actualizar " + userstoriessprinthistorialController.getMensaje());
                        }
                    } else {
                        if (!userstoriessprinthistorialController.insert(userstoriessprinthistorial)) {
                            Mensajeria.MensajeWarning("No se pudo insertar " + userstoriessprinthistorialController.getMensaje());
                        }
                    }

                }
            }

        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "guardarHistorialTablero()");
        }
    }
}
